This will format a positive or negative number with or without a dollar sign or a decimal point quickly. It will take any value up to 190 chars long and strip all chars except 0 - 9 and return a formatted number with or without a dollar sign or a decimal in the form:
(-)($)###,###,###(.)##
This is free. All I ask is to be notified of any suggestions or bugs found, and a credit line if you use it in released stacks. C source available on request.
Copyright 1988. All rights reserved.
Dwight Mayo
GEnie, MacNet - DMAYO
Compuserve - 76257,3303
-- part contents for background part 27
----- text -----
XFCN
-- part contents for background part 7
----- text -----
Syntax:
formatNum(Value,DollarSign,DecimalPoint)
Value can be any char and up to 190 chars long. formatNum will strip any char that is not a negative sign or a number (between 0 and 9) and will return a positive or negative formatted number in one of 4 forms: ┬▒###,### - ┬▒###,###.## - ┬▒$###,### - ┬▒$###,###.## depending on the included parameters.
*****NOTE: You must include the negative sign if this is to be a negative number (e.g.,-123). *****
if DollarSign is zero or left out, then no "$" wil be included.
if DollarSign is a 1, then a "$" will be included.
if DecimalPoint is zero or left out, then no "." will be included.
if DecimalPoint is a 1, then a "." will be included.
NOTE: You must supply the chars that are to be placed after the decimal point. This external simply grabs the last 2 chars of the number and places them after the decimal. If you ask for a decimal and pass only one char, then formatNum will return empty (nothing).
In a future release, I will add checking to pad the number with 0's if necessary and extend the number of decimal places beyond 2.
By using the various combinations, you can get the 4 different formats.